import { DefaultNamingStrategy } from "typeorm";

import { snakeCase } from "@src/lib/string";

export class NamingStrategy extends DefaultNamingStrategy {
  columnName(
    propertyName: string,
    customName: string,
    embeddedPrefixes: string[]
  ): string {
    return snakeCase(
      embeddedPrefixes.concat(customName ? customName : propertyName).join("_")
    );
  }

  relationName(propertyName: string): string {
    return snakeCase(propertyName);
  }
}
